package com.imay.live.manager;

import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;

/**
 * Created by nick on 2017/9/4.
 */

public class GameLiveViewAnimManager {
    private ObjectAnimator closeViewShowAnim,closeViewHideAnim,switchViewShowAnim,switchViewHideAnim,userInfoViewShowAnim,userInfoViewHideAnim;
    private static class GameLiveViewAnimManagerHolder {
        private static final GameLiveViewAnimManager INSTANCE = new GameLiveViewAnimManager();
    }
    public static final GameLiveViewAnimManager getInstance() {
        return GameLiveViewAnimManagerHolder.INSTANCE;
    }
    private GameLiveViewAnimManager() {

    }

    public void startCloseViewShowAnim(View view){
        if (closeViewShowAnim == null&&view.getHeight()==0){
            return;
        }
        if (closeViewShowAnim == null){
            closeViewShowAnim = ObjectAnimator.ofFloat(view,"translationY",-(view.getHeight()*2),0).setDuration(1000);
        }
        closeViewShowAnim.start();

    }
    public void startCloseViewHideAnim(View view){
        if (closeViewHideAnim == null&&view.getHeight()==0){
            return;
        }
        if (closeViewHideAnim == null){
            closeViewHideAnim = ObjectAnimator.ofFloat(view,"translationY",0,-(view.getHeight()*2)).setDuration(1000);
        }
        closeViewHideAnim.start();

    }

    public void startUserInfoViewShowAnim(View view){
        if (userInfoViewShowAnim == null&&view.getHeight()==0){
            return;
        }
        if (userInfoViewShowAnim == null){
            userInfoViewShowAnim = ObjectAnimator.ofFloat(view,"translationY",-(view.getHeight()*2),0).setDuration(1000);
        }
        userInfoViewShowAnim.start();

    }
    public void startUserInfoViewHideAnim(View view){
        if (userInfoViewHideAnim == null&&view.getHeight()==0){
            return;
        }
        if (userInfoViewHideAnim == null){
            userInfoViewHideAnim = ObjectAnimator.ofFloat(view,"translationY",0,-(view.getHeight()*2)).setDuration(1000);
        }
        userInfoViewHideAnim.start();

    }

    public void startSwitchViewShowAnim(View view){
        if (switchViewShowAnim == null&&view.getHeight()==0){
            return;
        }
        if (switchViewShowAnim == null){
            switchViewShowAnim = ObjectAnimator.ofFloat(view,"translationY",view.getHeight()+100,0).setDuration(1000);
        }
        switchViewShowAnim.start();

    }
    public void startSwitchViewHideAnim(View view){
        if (switchViewHideAnim == null&&view.getHeight()==0){
            return;
        }
        if (switchViewHideAnim == null){
            switchViewHideAnim = ObjectAnimator.ofFloat(view,"translationY",0,view.getHeight()+100).setDuration(1000);
        }
        switchViewHideAnim.start();

    }


}
